home *** CD-ROM | disk | FTP | other *** search
/ QuickTime 2.0 Developer Kit / QuickTime 2.0 Developer Kit.iso / mac / MAC / Programming Stuff / Documentation / develop / develop Issue 20 / develop 20 code / QTTextSample / MyTraps.c < prev    next >
Encoding:
Text File  |  1994-10-14  |  1016 b   |  53 lines  |  [TEXT/KAHL]

  1. // Simple framework for Macintosh sample code
  2. //
  3. // Nick Thompson, DEVSUPPORT
  4. //
  5. // This file contains the trap detection related code code for the framework.
  6. // 
  7. // 9/16/94    nick    first cut
  8. //
  9. //    Copyright:    © 1992-4 by Apple Computer, Inc.
  10.  
  11.  
  12. #include <Types.h>
  13. #include <Traps.h>
  14. #include <OSUtils.h>
  15. #include <GestaltEqu.h>
  16.  
  17. #include "MyTraps.h"
  18.  
  19. short NumToolboxTraps(void);
  20. TrapType GetTrapType(short theTrap);
  21.     
  22. short NumToolboxTraps(void)
  23. {
  24.     if (NGetTrapAddress(_InitGraf, ToolTrap) == NGetTrapAddress(0xAA6E,ToolTrap))
  25.         return 0x0200;
  26.     else
  27.         return 0x0400;
  28. }
  29.  
  30. TrapType GetTrapType(short theTrap)
  31. {
  32.     if ((theTrap & 0x0800) > 0)
  33.         return ToolTrap;
  34.     else
  35.         return OSTrap;
  36. }
  37.  
  38. Boolean    TrapAvailable(short theTrap)
  39. {
  40.     TrapType tType;
  41.     Boolean isAvail;
  42.     
  43.     tType = GetTrapType(theTrap);
  44.     if (tType == ToolTrap)
  45.         {
  46.             theTrap &= 0x07FF;
  47.             if (theTrap >= NumToolboxTraps())
  48.                 theTrap = _Unimplemented;
  49.         }
  50.     
  51.     isAvail = NGetTrapAddress(theTrap, tType) != NGetTrapAddress(_Unimplemented, ToolTrap);
  52.     return isAvail;
  53. }